package com.wintop.youyuan.services.impl;

import static org.junit.Assert.*;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.wintop.youyuan.ajax.UserAjax;
import com.wintop.youyuan.model.BaseData;
import com.wintop.youyuan.model.DetailData;
import com.wintop.youyuan.model.PersonalsCondition;
import com.wintop.youyuan.model.Photo;
import com.wintop.youyuan.model.User;

public class TestUserServicesImpl {

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Test
	public void testUser() {
		User user = new User();
		user.setId(20);
		user.setName("许峰4");
		user.setPassword("1234567");
		user.setSex(1);
		user.setUserid("xufeng6");

		ApplicationContext ctx = new ClassPathXmlApplicationContext(
				"applicationContext.xml");
		UserAjax u = ctx.getBean("userAjax", UserAjax.class);
		u.setUser(user);
		// u.register();
		// u.login();
		u.checkIsHaveUser();
		// u.changePassword();
		// u.deleteUser();
		fail("Not yet implemented");
	}

	@Test
	public void testUserInformation() {
		User user = new User();
		user.setUserid("xufeng5");
		BaseData baseData = new BaseData(5, user.getUserid(), "864381832", 172,
				1, 100, 1, 1, 1, 1, "安徽-安庆", 1, "1993-10-8", "安徽-芜湖", "123");
		DetailData detailData = new DetailData(1, user.getUserid(), 1, 1, 1, 1,
				1, 1, "12", "12", "12", "12");
		PersonalsCondition personalsCondition = new PersonalsCondition(1,
				user.getUserid(), "12", 1, 1, 1, 1, 1, 1);
		ApplicationContext ctx = new ClassPathXmlApplicationContext(
				"applicationContext.xml");
		UserAjax u = ctx.getBean("userAjax", UserAjax.class);
		u.setBaseData(baseData);
		u.setDetailData(detailData);
		u.setPersonalsCondition(personalsCondition);
		// u.updateBaseData();
		// u.updateDetailData();
		u.updatePersonalsCondition();
		fail("Not yet implemented");
	}

	public void testPhoto() {
		User user = new User();
		user.setUserid("xufeng6");
		Photo photo = new Photo(0, user.getUserid(), "123456", null);

		ApplicationContext ctx = new ClassPathXmlApplicationContext(
				"applicationContext.xml");
		UserAjax u = ctx.getBean("userAjax", UserAjax.class);
		//u.setPhoto(photo);
		u.addPhoto();
		fail("Not yet implemented");
	}
}
